Helpful Information
 
 
Category: Embedded Programming
BEST Robotics Programming - Using diagonal on RC as a "button"

I am in BEST Robotics and part of the programming team. I don't really understand much of C, but we are trying to set it up so that on the controller we can use the diagonals to send out a certain IR signal from our IR transmitter. If I need to explain further, I can get some pictures later.

We can figure out the values we want to use for the IR (which uses the setServo command thing) but we aren't sure how to have the diagonals do what I said above, especially keeping them independent from the arm and grabber we have set on those same two channels, but independent from each other.

Insufficient information. First read this:

New user how to post a question - READ THIS FIRST (http://forums.devshed.com/c-programming-42/new-users-how-to-post-a-question-read-this-first-259106.html)

You are probably in the wrong forum anyway as your problem probably has more to do with algorithms or details of your control system than the C language. I suggest you start with the Software Design forum (http://forums.devshed.com/software-design-43/) and explain a lot more about the hardware you are using.

Ok sorry. I am using IAR Workbench, and my basic question is this: on the controller, the channels I want to mix are 3 and 4, which are turned into 2 and 3 when put into C. I'm not sure how to tell it to used the combination of those two, so any help would be great, but none is expected due to this being a fairly specific-to-this-program question.

Can't help you. Haven't a clue what those channels are used for, much less whether they can be "mixed". There may yet be a C language question in there somewhere, but we need more information. IAR Workbench can be used to target more than one processor and those can all be soldered to infinite permutations of board designs. Pointers to your controller docs would be very useful.

BTW, I would love to provide free consults on this project. You can find my contact information at www.odonahue.com. I have worked a handful of robotics projects over the years and am fairly familiar with IAR Workbench and most of the hardware/software that goes into developing robotics. I can also connect you with other experts in the field, who are usually willing to assist on student projects (schedules allowing), if/when you should need them.

While I have not been active at the Seattle Robotics Society (http://www.seattlerobotics.org/) since the late 80's, I drop in on them from time to time and I am sure we can find expert assistance among their members, even if some of them may be mentoring other BEST competitors. You may also be able to find a local Robotics Society or equivalent club in your own area. It's always easier to help with these things when you can physically touch the equipment involved and communications bandwidth is always highest face to face.

Click this link (http://www.bestinc.org/MVC/FileManagement/list?dir=46) then look at the Advanced Brain powerpoint.

That site has some files, namely the one called Advanced Team Training. This gives some basic information, as well as some more advanced information and some basic programming and some syntaxes for this specific thing. Does that help?

Got it. I'll take a look.

Ok, here's an example of poorly written, non-defensive code:



for (chan=0;chan!=4;chan++)
{
inval=getRcValue(chan,8,100); // no gain, ok deadband

// insert other processing with the input values

setServo(chan,inval); // set the servo position
setMotor(chan,inval); // set the motor speed
} // for loop


Never mind their failure to use the one true bracing style. Take a look at the for loop conditional. If chan ever winds up greater than 4, this puppy runs off into the weeds screaming like R2 with a power overload. That should be chan < 4 kids. Please don't follow their examples at home and do wear protective clothing.

Of course, in this trivial example, chan is likely to remain within the range (0..4], but this stuff gets picked up by folks who are just learning how to code, and they go off and add all kinds of things to it and before you know it, somebody's on their way to an emergency room and/or the school nurse is spritzing bleach all over the bot to clean off the blood.

Whoever wrote the code for that power point presentation should be fired.

I get what you're saying, and it made me laugh really hard. (I like to make -ist jokes, so the following is meant to JUST BE A JOKE, no matter how truthful the information is) It's probably because that person is a girl. Ha.

And we're not using that certain program because it's simply lame and hard to work with without redoing it completely.

Anyways, do you now understand what I'm trying to do with the diagonals? I understand how to program the IR to work, just not how to assign it to diagonals.

However, just my brain thinking and people talking, I thought that if you could put in some like "for (chan2=1024) etc...not sure how to write that so that it doesn't just flop over and die, but oh well.

inval=getRcValue(chan,8,100); // no gain, ok deadband

The "magic numbers" here (8, 100) should be replaced with appropriately named const's.

This may be a stupid question:

What is "the diagonal", and where in the documentation can I find information re: "the diagonal".

Anyways, do you now understand what I'm trying to do with the diagonals? I understand how to program the IR to work, just not how to assign it to diagonals.

Not there yet. Perhaps you could explain what you mean by "assign it to diagonals"?

So here's a major design flaw:



Diagnostic LEDs (D41/D42) indicate status:
* D41 – Control Processor; D42 – User Processor
* Slow blink (once per second) – normal operation
* Fast blink (five times per second) – absence of tether/receiver signal, or absence of communication between processors.
* Solid on/off – something is hung up, cycle power first then reprogram if power cycle doesn’t solve.


So, there's lots of ways that a failure can masquerade as either the slow blinking normal mode or the fast blinking "missing signal" indicator. I once watched a crane operator load an entire rail car full of scrap metal, thinking our industrial crane scale was working correctly, when it fact, it was resetting itself at almost exactly the same rate as the "slow blinking normal indicator" rate. LOL. You may need to turn that thing off and generate your own diagnostic outputs.

Maybe it'll let me post URLs now.
In the representation on one of the joysticks shown below, the colored parts are what I mean by diagonals.

http://img26.imageshack.us/img26/2872/94875056.png

Sorry for not being very informative. I just don't quite know what I need to tell. And thanks for the help and for putting up with me. =P

Ick! I won't be visiting their public message board:



Public Message Board (for anyone)
* Must register for Yahoo login account
* Share ideas, resolve issues, …
*http://tech.groups.yahoo.com/group/bestinc

Okay, so you've established that you must be able to obtain diagonal inputs from the joystick.

Once those inputs are obtained, what must occur next?

If this sounds simplistic, please understand that I'm trying to help you form the logic in your native language.

If you can state clearly in english the steps that must be undertaken, then the code you write will be a reflection of that.

Insufficient iinformation. You also mentioned some sort of IR output. What's that got to do with the joystick?

I understand that reasoning.

Here's what I want. I push the joystick to the top right diagonal and have the IR transmitter send a signal of 200 (units?). To get the IR part, I know that I use the setServo command and use a value of 200, so whatever code it is to use the "diagonals", it will need to have the following code in it somewhere.


setServo(0,200)

The 0 is to tell which servo to move. I just decided to use 0 for this.

@jwdonahue: The IR I mentioned is treated as a servo within the BRAIN, and we are trying to use the joystick diagonals to send IR signals.

I still don't have a good enough design picture in my head here.

So you're problem is figuring out how read when the joystick is on one of the diagonals? Is the right?

Well it seems you already got your answer at the Yahoo site:

http://tech.groups.yahoo.com/group/bestinc/message/940

How's that working for you?

Ha yes I just saw that reply. I'm at home so I can't program the BRAIN to find out if it works, but I'll try it as soon as I can.

I have most of the errors sorted out, but at the second { bracket, it says "error-expected a declaration" so I'm not sure what to change there because it looks fine to me.

void outInt(char* label,int n)
{
char szTemp[16];
outHostsz(label);
itoa(n,szTemp);
outHostsz(szTemp);
}

{

InitBrain();

setServoRange(IR_SERVO,180);
}










privacy (GDPR)